package config

import (
	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

var DB *gorm.DB

func ConnectDatabase() {
	dsn := "host=localhost user=dhx password=LKJSGsk*@1kj20 dbname=daohuaxiang port=5432 sslmode=disable"
	//dsn := "root:89374*(&%$^@#jkjsf@tcp(127.0.0.1:3306)/daohuaxiang?charset=utf8mb4&parseTime=True&loc=Local"
	database, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})

	if err != nil {
		panic("Failed to connect to database")
	}

	DB = database
}
